package com.htsk.city.services.wechat.params;

import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONUtil;
import com.htsk.city.services.core.domain.Post;
import com.htsk.city.services.core.domain.WxUser;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

@Data
public class PublishPostsParam {

    private String content;
    private String location;
    private List<Long> topicIds;
    private List<String> images;
    private BigDecimal latitude;
    private BigDecimal longitude;

    public Post trans(WxUser wxUser){
        Post post = new Post();
        post.setLocation(this.location);
        post.setContent(this.content);
        post.setCreatedAt(DateUtil.date());
        post.setUpdatedAt(DateUtil.date());
        post.setUserId(wxUser.getId());
        post.setImages(JSONUtil.toJsonStr(images));
        post.setVisibility(1);
        post.setLikeCount(0);
        post.setCommentCount(0);
        post.setDelFlag(0);
        post.setBrowseCount(0);
        post.setLatitude(this.latitude);
        post.setLongitude(this.longitude);
        return post;
    }
}
